/**
  * Author: Mei
  * Date: 2020-12-10 20:44
  * Description: 变化的模板  变化的是个数和类型
  *
  */
#include "../head.h"

using namespace std;

template<typename ... Values>
class tuple1; //先定义  后面才能使用偏特例化

int k = 8;

template<>
class tuple1<> {
public:
    tuple1() {
        cout << "show time, k = " << k-- << endl;
    }
};

template<typename Head, typename ...Tail>
class tuple1<Head, Tail...> : private tuple1<Tail...> {  //递归调用
    typedef tuple1<Tail...> inherited; //为一包的类型
public:
    explicit tuple1() {}
    //inherited(vtail...) 调用父类的构造函数  每次inherited就为剩下的一包
    tuple1(Head v, Tail ... vtail) : m_head(v), inherited(vtail...) {
        cout << "tuple1(),v = " << v << ", k = " << k-- << endl;
    }
    Head head() { //取head
        return m_head;
    }
    //auto head() -> decltype(m_head){
    //    return m_head;
    //}

    //返回剩下的一包
    inherited &tail() {
        return *this;
    }

protected:
    Head m_head;
};

int main() {
    tuple1<string, int, float, string> t("nico", 12, 4.3, "nico");
    cout << t.head() << endl;
    cout << t.tail().head() << endl;

    return 0;
}

